/**
 *******************************************************************************
 * @FileName  : hci_tr_def.h
 * @Author    : GaoQiu
 * @CreateDate: 2020-09-10
 * @Copyright : Copyright(C) GaoQiu
 *              All Rights Reserved.
 *
 *******************************************************************************
 *
 * The information contained herein is confidential and proprietary property of
 * GaoQiu and is available under the terms of Commercial License Agreement
 * between GaoQiu and the licensee in separate contract or the terms desc ribed
 * here-in.
 *
 * This heading MUST NOT be removed from this file.
 *
 * Licensees are granted free, non-transferable use of the information in this
 * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided.
 *
 *******************************************************************************
 */
#ifndef HCI_TR_DEF_H_
#define HCI_TR_DEF_H_

#include "utils/track.h"

/*!  HCI Transmit Type. */
#define HCI_TR_TYPE_NONE      0x00
#define HCI_TR_TYPE_CMD       0x01
#define HCI_TR_TYPE_ACL       0x02
#define HCI_TR_TYPE_SCO       0x03
#define HCI_TR_TYPE_EVENT     0x04

/*!  HCI Head length define. */
#define HCI_CMD_HEAD_LEN  3
#define HCI_ACL_HEAD_LEN  4
#define HCI_EVT_HEAD_LEN  2
#define HCI_SCO_HEAD_LEN  3


/*! H5 packet length macro. */
#define HCI_H5_HEAD_LEN        4
#define HCI_H5_CRC_LEN         2


#define MEM_SIZE_ALIGN4(x)    MEM_ALIGNED_SIZE(x, 4)
#define MEM_SIZE_ALIGN16(x)   MEM_ALIGNED_SIZE(x, 16)

#define HCI_BUF_SIZE_ALIGN4(payload)          MEM_SIZE_ALIGN4(1 + HCI_ACL_HDR_LEN + payload)
#define HCI_BUF_SIZE_ALIGN16(payload)         MEM_SIZE_ALIGN16(1 + HCI_ACL_HDR_LEN + payload)

#define HCI_TR_BUF_SIZE_ALIGN4(payload)       MEM_SIZE_ALIGN4(4 + payload) // 4 for DMA Length
#define HCI_TR_BUF_SIZE_ALIGN16(payload)      MEM_SIZE_ALIGN16(4 + payload)// 4 for DMA Length


/*! Common error */
#define HCI_TR_ERR_INVALID_PARAM        0x00010000

/*! HCI H5 Protocol error */
#define HCI_TR_ERR_H5_HEAD_LEN          0x01010000
#define HCI_TR_ERR_H5_TX_BUF_OVFL       0x01020000
#define HCI_TR_ERR_H5_HCI_RX_BUF_OVFL   0x01030000

/*! HCI Slip Protocol error */
#define HCI_TR_ERR_SLIP_ESCAPE          0x02010000
#define HCI_TR_ERR_SLIP_ENCODE_BUF      0x02020000
#define HCI_TR_ERR_SLIP_DECODE_BUF      0x02030000

/*! HCI Transport error */
#define HCI_TR_ERR_TR_BACKUP_BUF        0x03010000
#define HCI_TR_ERR_TR_TX_BUF            0x03020000

#endif /* HCI_TR_DEF_H_ */




